<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>测试</title>
</head>
<body>
    <script>
        function f(){
            window.setTimeout("populate()", 2000)
        }
        function populate() {
            document.f1.t1.value = "populate";
            document.getElementById("id1").innerHTML = "<div id=\"id2\">id2</div>"
        }
    </script>
    <form name="f1">
        <input type="text" name="t1">
        <input type="button" id="btn" value="Click me" onclick="f()">
        <div id="id1"></div>
    </form>
</body>
</html>